/*************************************************************************
	> File Name: EP52.c
	> Author: 
	> Mail: 
	> Created Time: 
 ************************************************************************/
#include <stdio.h>

int check(int *num, int n) {
    while (n) {
        if (num[n % 10] == 0) return 0;
        n /= 10;
    }
    return 1;
}

int is_val(int n) {
    int num[10] = {0}, x = n;
    while (x) {
        num[x % 10] = 1;
        x /= 10;
    }
    for (int i = 2; i <= 6; i++) {
        if (!check(num, n * i)) return 0;
    }
    return 1;
}

int main() {
    int n = 0;
    while (1) {
        n += 1;
        if (!is_val(n)) continue;
        printf("%d\n", n);
        break;
    }
    return 0;
}
